# -*-coding=UTF-8-*-
# !/usr/bin/python
import os

def gram():
    print '字符串可用单双引号\"转义字符'
    # 字符串可以相乘，注释前需要空行
    print '='*10
    username = "zy"
    print "字符串连接"+username

def add_num():
    # 算术运算符 +-*/%  取整// 幂**
    print 8/5.0
    print 8//5.0
    print 3**2


def var():
    # String数据类型
    username = password = "root"
    print "mysql数据库的用户名是 %s 密码是 %s" % (username, password)
    name1, name2 = "张三", "李四"
    print name1 + "-"*10 + name2
    print "字符串第2-4位序列"+username[2:4]

    # numbers数据类型
    int_count = 0x69
    float_num = -32.54e100
    # 复数类型 a+bj
    complex_num = 9.322e-36j
    long_num = 51924361L
    print int_count
    print float_num
    print long_num
    print complex_num

    # List列表数据类型,列表*2
    foo = ['列表', "test", "可以是多种类型"]*2

    for i in foo:
        print i
    del foo[1]
    print str(foo)
    print "列表倒数第一个元素:" + foo[-1]

    # tuple元组数据类型,为什么打印出来是ascii码
    otu = ("相当于只读列表", "不能二次赋值", "少用", "场景")
    print otu[2:3]
    # print otu

    # 当只有一个元素时，要加,
    tup1 = (50,)
    print tup1

    # DICT字典
    dict_obj = {"name": "朱艳", "age": 5}
    print dict_obj
    # print dict_obj[0]
    print dict_obj["name"]
    # 向字典新增元素
    dict_obj["home"] = "China"
    print len(dict_obj)
    del dict_obj["age"]   # 删除字典元素
    # dict_obj.clear()   # 清空字典条目
    # del dict_obj   # 删除字典
    print dict_obj

    dict_obj2 = {"name": "Sellina", "age": 25}
    dict_obj.update(dict_obj2)
    print dict_obj



def convert():
    a = "5"
    print str(a)
    print hex(110)


def cycle():
    # 内置函数从0-10
    for j in range(10):
        print j

    count = 2
    # 用and or表示&&，||
    if(count > 0) and (count != 1):
        print "大于0且不等于1"
    elif count == 1:
        print "count为1"

    ''' 多行文本注释
多行 '''

# 只有对自身模块测试才写这段代码。
if __name__ == '__main__':
    # gram()
    # cycle()
    var()
    # convert()


